package io;

import java.io.*;

/**
 * 输入输出缓冲流
 * 缓冲流内部有一个默认）为8k的缓冲区（字节数组）
 *
 * BufferedInputStream
 *
 * public BufferedInputStream(InputStream in)
 * */
public class BufferedInputOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        BufferedInputStream inBuffer = new BufferedInputStream(
                new FileInputStream("src/io/BufferedInputOutputStreamDemo.java"));
        BufferedOutputStream outBuffer = new BufferedOutputStream(
                new FileOutputStream("files/ttt.ttt"));
        int b;
        while ((b = inBuffer.read()) != -1)
            outBuffer.write(b);
//        outBuffer.flush();  // 刷新缓冲区，即强制溢出到目的地，若缓冲区未满则（即使流关闭时）不会溢出，即目的地收不到数据
        outBuffer.close();  // 关闭流并释放所占用的系统资源，此方法会调用flush()方法刷新缓冲区
        inBuffer.close();
    }
}
